import 'package:enterprise_v6_app/app/components/special_operation/custom_select_function.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/core/http/http.dart';
import 'package:enterprise_v6_app/app/core/utils/interface.dart';
import 'package:enterprise_v6_app/app/data/entities/application/standardiztion/standardization_entity.dart';
import 'package:enterprise_v6_app/app/modules/application/standardization/pages/risk/hazard/model.dart';

/// 重大危险源
class StandardizationRiskHazardController extends GetxController {
  var type = StandardizationRiskHazardMenuType.all.first;

  Future<List<StandardizationEntity>> getPages(int idx, int size, {String? search}) async {
    final resp = await HttpUtil().generateGetRequest<List<StandardizationEntity>>(
      '${Interface.mainBaseUrl}${type.path}',
      queryParameters: {
        'pageNum': idx,
        'pageSize': size,
        'name': search,
      },
    ).execute();
    return resp.data ?? [];
  }

  void showSelect() {
    CustomSelectFunction.selectMultipleBottomSheet<StandardizationRiskHazardMenuType>(
      onCallBack: (val) {
        type = val.first;
        update();
      },
      dataList: StandardizationRiskHazardMenuType.all,
      checkedList: [type],
      isMultiple: false,
    );
  }
}